﻿//=============================================================================
// Project  : NIPO Component Framework
// File    : ServicePlugin.cs
// Author  : Bernhard Dieber (Bernhard.Dieber@uni-klu.ac.at)
// Copyright 2010 by Bernhard Dieber
// This code is published under the Microsoft Public License (Ms-PL).  A copy
// of the license should be distributed with the code.  It can also be found
// at the project website: http://NIPO.CodePlex.com.   This notice, the
// author's name, and all copyright notices must remain intact in all
// applications, documentation, and source files.
//=============================================================================

using NIPO.Controller;
using NIPO.Data;
namespace NIPO.Plugins
{
    /// <summary>
    /// Service plugins provide generic services to other plugins.<br />
    /// NIPO contains a service discovery functionality to find suitable services during runtime using the <see cref="Service"/> class.
    /// <seealso cref="Controller.Service"/>
    /// </summary>
    public abstract class ServicePlugin : Plugins.Plugin
    {

        /// <summary>
        /// Gets the name of the service.
        /// </summary>
        /// <value>The name of the service.</value>
        public virtual string ServiceName { get { return Name; }
        }
        /// <summary>
        /// Gets the service description.
        /// </summary>
        /// <value>The service description.</value>
        public virtual string ServiceDescription { get { return Description; } }

        ///<summary>
        /// Generic service access.<br />
        /// Takes a DTO as input and returns a corresponding DTO. The actual function of this service should be determined through the service discovery and compatibility check.
        ///</summary>
        ///<param name="input">The input DTO</param>
        ///<returns>The corresponding result DTO</returns>
        public abstract DataTransferObject PerformService(DataTransferObject input);

        /// <summary>
        /// Determines whether this instance can process the specified input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns>
        /// 	<c>true</c> if this instance can process the specified input; otherwise, <c>false</c>.
        /// </returns>
        public bool CanProcess(DataTransferObject input)
        {
            DataTransferObject output;
            return CanProcess(input, out output);
        }

        /// <summary>
        /// Determines whether this instance can process the specified input.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <param name="output">The output.</param>
        /// <returns>
        /// 	<c>true</c> if this instance can process the specified input; otherwise, <c>false</c>.
        /// </returns>
        public abstract bool CanProcess(DataTransferObject input, out DataTransferObject output);
    }
}